package com.vue.vuedemo.controller;

import com.vue.vuedemo.annotation.CheckToken;
import com.vue.vuedemo.map.CategoryMapper;
import com.vue.vuedemo.pojo.Category;
import com.vue.vuedemo.viewpojo.ResList;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
public class CategoryController {

    @Autowired
    CategoryMapper categoryMapper;
    
    @CheckToken
    @GetMapping("/getimgcategory")
    public ResList<Category> getimgcategory(HttpServletResponse response){
        response.setHeader("Access-Control-Allow-Origin", "*");
        List<Category> allCategory = categoryMapper.getAllCategory();
        
        ResList<Category> resList = new ResList<Category>();
        resList.setStatus(0);
        resList.setMessage(allCategory);
        
        
        return resList;
    }

}
